<script type="text/javascript">
    $(function(){
        $("input[name='confirm_workCenterCode']",navTab.getCurrentPanel()).click(function(){
            var $this = $(this);
            var checked = $this.attr("checked");
            if(!checked){
                $("input[name='confirm_workCenterCodeStr']",navTab.getCurrentPanel()).attr("checked", false);
            }else{
                var allChecked = true;
                $("input[name='confirm_workCenterCode']",navTab.getCurrentPanel()).each(function(){
                    if(!$(this).attr("checked")){
                        allChecked =  false;
                    }
                });
                if(allChecked) $("input[name='confirm_workCenterCodeStr']",navTab.getCurrentPanel()).attr("checked", true);
            }
            reloadConfirmDetail();
        });
        
        $("input[name='confirm_workCenterCodeStr']", navTab.getCurrentPanel()).click(function(){
            var $trigger = $(this);
            var group = $trigger.attr("group");
            if ($trigger.is(":checkbox")) {
                var type = $trigger.is(":checked") ? "all" : "none";
                if (group) $.checkbox.select(group, type, navTab.getCurrentPanel());
                if(type=="all")
                    reloadConfirmDetail();
            }
        })
        
    })
    function reloadConfirmDetail() {
        var workCenterStr = "";
        var allChecked = $("input[name='confirm_workCenterCodeStr']",navTab.getCurrentPanel()).attr("checked");
        if(allChecked){
            workCenterStr = "-1";
        }else{
            $("input[name='confirm_workCenterCode']",navTab.getCurrentPanel()).each(function(){
                if($(this).attr("checked")){
                    workCenterStr += ",'"+$(this).val()+"'";
                } 
            })
        }
        //不为空再刷新
        if(workCenterStr!=""){
            if(workCenterStr!="-1")
                workCenterStr = workCenterStr.substring(1);
            var productionNum = $("input[name='productionNum']").val();
            $("div#archives_workCenterTotal", navTab.getCurrentPanel()).loadUrl(hostUrl+"/confirmDetails/confirmDetails_one", {'workCenterCodeStr':workCenterStr, 'productionNum':productionNum});
            $("div#archives_confirmDetails", navTab.getCurrentPanel()).loadUrl(hostUrl+"/confirmDetails/confirmDetails_two", {'workCenterCodeStr':workCenterStr, 'productionNum':productionNum},
                    function(){ $("div#archives_confirmDetails",navTab.getCurrentPanel()).find(".gridScroller").layoutH()});
        }
    }
</script>
<div id="wokeCenters" style="height: 50px;">
    <fieldset>
        <legend><@label key='workCenter.C'>工作中心</@label></legend>
        <dl style="text-align: left;">
            <input type="checkbox" name="confirm_workCenterCodeStr" checked group="confirm_workCenterCode"  value="-1"/> <@label key="all.C">所有</@label>
            <#if confirmDetails??>
                <#list confirmDetails as cofirm>
                    <input type="checkbox" name="confirm_workCenterCode" checked value="${cofirm.workCenterCode!''}" />${cofirm.workCenterText!''}
                </#list>
            </#if>
        </dl>
    </fieldset>
</div>
<div layoutH="50">
    <div id="archives_workCenterTotal" style="float:left;width:30%;border: 1px #d8dfe5 solid;border-top: 0px;" layoutH="100">
        <div class="panelBar">
            <ul class="toolBar">
                <li style="margin-top: 8px;"><h1 style="text-align:left;">统计信息</h1></li>
            </ul>
        </div>
        <table class="table">
            <thead>
                <tr>
                    <th width="30"><@label key="serialNumber.C">序号</@label></th>
                    <th width="100" ><@label key="workCenterCode.C">工作中心</@label></th>
                    <th width="80"><@label key='plannedQuantity.C'>计划数量</@label></th>
                    <th width="80"><@label key='completedQuantity.C'>完工数量</@label></th>
                </tr>
            </thead>
            <tbody>
            <#list confirmDetails as confirm>
                <tr>
                    <td>${confirm_index + 1}</td>
                    <td>${confirm.workCenterCode!''}</td>
                    <td>${confirm.plannedQuantity!''}</td>
                    <td>${confirm.completedQuantity!''}</td>
                </tr>
            </#list>
            </tbody>
        </table>
    </div>
    <div id="archives_confirmDetails" style="float:right;width:69%;border: 1px #d8dfe5 solid;border-top: 0px;" layoutH="100">
        <#include "/common/pagerForm.html">
        <form rel="pagerForm" method="post" action="${rc.getContextPath()}/manage/confirmDetails/confirmDetails_two" onsubmit="return  dwzSearch(this, 'dialog');">
        <input type="hidden" name="productionNum" value="<#if condition??>${condition.productionNum!''}</#if>" />
        <input type="hidden" name="workCenterCodeStr" value="<#if condition??>${condition.workCenterCodeStr!''}</#if>" />
        <div class="panelBar">
            <ul class="toolBar">
                <li style="margin-top: 8px;"><h1 style="text-align:left;">报工信息</h1></li>
            </ul>
        </div>
        <table class="table" layoutH="220">
            <thead>
                <tr>
                    <th width="40"><@label key="serialNumber.C">序号</@label></th>
                    <th width="120"><@label key='productionControlNum.C'>生产管理号</@label></th>
                    <th width="80"><@label key='productionlotNum.C'>生产批次号</@label></th>
                    <th width="80"><@label key='completedQuantity.C'>完工数量</@label></th>
                    <th width="80"><@label key="confirmUser.C">报工人</@label></th>
                    <th width="100"><@label key="confirmDateTime.C">报工时间</@label></th>
                    <th width="100"><@label key="workCenterCode.C">工作中心</@label></th>
                    <th width="100"><@label key="workUnit.C">作业单元</@label></th>
                    <th width="80"><@label key="operation.C">工序</@label></th>
                    <th width="80"><@label key="customer.C">客户</@label></th>
                    <th width="100"><@label key="customerOrder.C">客户订单</@label></th>
                    <th width="50"><@label key="priority.C">优先级</@label></th>
                </tr>
            </thead>
            <tbody>
            <#if page?? && (page.data?size>0)>
                <#list page.data as confirm>
                    <tr>
                        <td>${page.startRow + confirm_index}</td>
                        <td>${confirm.productionControlNum!''}</td>
                        <td>${confirm.productionLotNum!''}</td>
                        <td>${confirm.completedQuantity!''}</td>
                        <td>${confirm.confirmUser!''}</td>
                        <td>${(confirm.confirmDateTime?string("yyyy-MM-dd"))?if_exists}</td>
                        <td>${confirm.workCenterCode!''}</td>
                        <td>${confirm.workUnitCode!''}</td>
                        <td>${confirm.operationCode!''}</td>
                        <td>${confirm.customer!''}</td>
                        <td>${confirm.customerOrder!''}</td>
                        <td>${confirm.priority!''}</td>
                    </tr>
                </#list>
            </#if>
            </tbody>
        </table>
        <div class="panelBar" style="border-width: 1px;">
            <#if page??>
            <div class="pages">
                <span ><@label key="pagePanelShow.C">显示</@label></span> <select class="combox" name="numPerPage"
                    onchange="navTabPageBreak({numPerPage:this.value},'archives_confirmDetails')"> <#list
                    [10,20,30,50,100,200] as page_size> <#if
                    (page.numPerPage)==page_size>
                    <option value="${page_size}" selected="selected">${page_size}</option>
                    <#else>
                    <option value="${page_size}">${page_size}</option> </#if> </#list>
                </select> <span><@label key="pagePanelMiddle.C">共</@label></span><span><#if page.totalCount??>${page.totalCount?c}<@label key="item.C">条</@label></span></#if>
            </div>
    
            <div class="pagination" targetType="navTab" rel="archives_confirmDetails"
                totalCount="<#if page.totalCount??>${page.totalCount?c}</#if>"
                numPerPage="<#if page.numPerPage??>${page.numPerPage?c}</#if>"
                pageNumShown="5"
                currentPage="<#if page.pageNum??>${page.pageNum?c}</#if>"></div>
            </#if>
        </div>
        </form>
    </div>
</div>